from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
from WMS_unittest.tools_unit import Tools
import unittest
import logging

class Wms(unittest.TestCase):
    def setUp(self) -> None:
        Tools().log1()
        self.driver = webdriver.Edge()
        self.driver.get('http://10.59.9.32/jeewms/loginController.do?login')
        self.driver.maximize_window()
        sleep(2)

    def tearDown(self) -> None:
        sleep(5)
        self.driver.quit()

    def test_delete_record(self):
        try:
            logging.info("*****************************************")
            # 进货管理-收货登记-删除记录
            sleep(5)
            self.driver.find_element(By.ID, 'but_login').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="sidebar"]/ul/li[9]/a').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="sidebar"]/ul/li[9]/ul/li[6]/a').click()
            sleep(2)
            self.driver.switch_to.frame(
                self.driver.find_element(By.XPATH, '//*[@id="tab_8a7ba3345d9e6e2b015da54f7ffe0238"]/iframe'))
            sleep(2)
            self.driver.find_element(By.NAME, 'imCusCode').send_keys('6')
            self.driver.find_element(By.NAME, 'goodsId').send_keys('8')
            self.driver.find_element(By.XPATH, '//*[@id="datagrid-row-r1-1-0"]/td[2]/div').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="datagrid-row-r1-2-0"]/td[1]/div/a[1]').click()
            sleep(2)
            self.driver.find_element(By.XPATH, '//*[@id="layui-layer1"]/div[3]/a[2]').click()
            dy = self.driver.find_element(By.XPATH, '//*[@id="wmInQmIListtb"]/div[2]/span[1]/a[3]/span/span').text
            print(dy)
            self.assertIn(dy, '批量更改储位')
            sleep(2)
            logging.info("*****************************************")
        except Exception as e:
            print(e)



if __name__ == '__main__':
    unittest.main()
